import wepy from 'wepy'

export default class TrackerMarker extends wepy.mixin {
  data = {
    markers:[]
  }
  computed = {
    markers() {
      return this.markers
    }
  }

  settrackermarker(data,show){
    let self=this
    let newmarkers=[]
    if(data.lat && data.lat>0){
      let obj={},updateTime='', rssi = '',satellites = '';
      let newP = this.wgs84togcj02(data.lng, data.lat)
      data.rssi <= 10 ? rssi = '弱' : data.rssi <= 20 ? rssi = '一般' : rssi = '强';
      data.satellites <= 6 ? satellites = '弱' : data.satellites <= 14 ? satellites = '一般' : satellites = '强';
      if(data.updateTime) updateTime=self.formatTime(new Date(data.updateTime))

      obj.iconPath="../assets/mapimg/location1.png"
      obj.latitude= newP[1]
      obj.longitude= newP[0]
      obj.width= 35
      obj.height= 35
      obj.id= data.trackerId
      obj.callout={
        content:` IMEI号:${data.imei}\n 设备编号:${data.trackerId}\n 通信信号:${rssi}\n GPS信号:${satellites}\n 定位时间:${updateTime}\n 查看详情`,
        display: show===1?'ALWAYS':'BYCLICK',
        bgColor: '#00000080',
        color: '#ffffff',
        textAlign: 'left',
        borderRadius: 15,
        padding: 15,
        fontSize: 15
      }

      newmarkers.push(obj)
    }

    this.markers=newmarkers
    self.$apply()
  }
}
